/**
 *  Eclipse Public License 1.0
 */
package org.fireblade.easysms;

import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

/**
 * receives button events on off for wifi
 */
public class Wifi_USBManualListener implements OnClickListener {
  /**
   * own log tag
   */
  private static final String LOGTAG = MainActivity.EASY_SMS + Wifi_USBManualListener.class.getSimpleName();
  /** the action */
  protected String action = null;


  protected Wifi_USBManualListener(String action) {
    this.action = action;
  }


  public void onClick(View v) {
    Log.d(LOGTAG, "Button clicked, action " + action);
    Intent intent = new Intent(v.getContext(), Wifi_USBEventReceiver.class);
    intent.setAction(Wifi_USBEventReceiver.ACTION_WIFI_MANUAL);
    intent.putExtra(Wifi_USBEventReceiver.ACTION, action);
    v.getContext().sendBroadcast(intent);
    Log.d(LOGTAG, "Service notified.");
    String text = "Wifi/USB Service "
      + ((action.equals(Wifi_USBEventReceiver.MANUAL_ON)) ? v.getResources().getString(R.string.str_started) : v
        .getResources().getString(R.string.str_stopped));
    Toast.makeText(v.getContext(), text, Toast.LENGTH_SHORT).show();
  }

}
